package com.jxlg.execrise.service;

import com.jxlg.execrise.mapper.StudentMapper;
import com.jxlg.execrise.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class StudentService {
    //注入持久层
    @Autowired
    private StudentMapper studentMapper;

    public  Student select(int id){
        //进行逻辑判断
        Student student=studentMapper.selectByPrimaryKey(id);
        return student;
    }

    public List<Student> selectAll(){
        List<Student> students=studentMapper.selectAll();
        return students;

    }

    public Student insertData(){
        Student student=new Student();
        student.setAge(20);
        student.setName("Jack");
        student.setBirthday(new Date());
        student.setSalary(6000);
        studentMapper.insert(student);
        return student;

    }

   public int deleteData(int id){
         int student=studentMapper.deleteByPrimaryKey(id);
         return student;
    }


}
